/**
 * 
 */
package ve.com.neometrica.inventario.impl.dao;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import ve.com.neometrica.inventario.api.dao.TransaccionDao;
import ve.com.neometrica.inventario.api.model.Transaccion;

/**
 * @author a.cabrera
 *
 */
public class TransaccionDaoImpl extends HibernateDaoSupport implements
		TransaccionDao {

	/* (non-Javadoc)
	 * @see ve.com.neometrica.inventario.api.dao.TransaccionDao#save(ve.com.neometrica.inventario.api.model.Transaccion)
	 */
	@Override
	public void save(Transaccion transaccion) {
		if(transaccion.getId()==null){
			getHibernateTemplate().save(transaccion);
		}else{
			getHibernateTemplate().saveOrUpdate(transaccion);
		}
	}

	/* (non-Javadoc)
	 * @see ve.com.neometrica.inventario.api.dao.TransaccionDao#getAll()
	 */
	@Override
	public List<Transaccion> getAll() {
		return this.getHibernateTemplate().loadAll(Transaccion.class);
	}

	/* (non-Javadoc)
	 * @see ve.com.neometrica.inventario.api.dao.TransaccionDao#getById(java.lang.Integer)
	 */
	@Override
	public Transaccion getById(Integer id) {
		return this.getHibernateTemplate().load(Transaccion.class, id);
	}

}
